//
//  SISSReciveWarmTipViewController.m
//  SISSAPP
//
//  Created by 优房网 on 2017/9/7.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSReceivedWarmTipViewController.h"

@interface SISSReceivedWarmTipViewController ()

/* contentLabel */
@property (weak, nonatomic) UILabel *contentLabel;

@end

@implementation SISSReceivedWarmTipViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"温馨提示";
}

- (void)setTextStr:(NSString *)textStr {
    _textStr = textStr;
    
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    //    paraStyle.alignment = NSTextAlignmentLeft;  //对齐
    //    paraStyle.headIndent = 0.0f;//行首缩进
    //参数：（字体大小17号字乘以2，34f即首行空出两个字符）
    //    CGFloat emptylen = self.contractOneLabel.font.pointSize * 2;
    //    paraStyle.firstLineHeadIndent = emptylen;//首行缩进
    //    paraStyle.tailIndent = 0.0f;//行尾缩进
    paraStyle.lineSpacing = 16.0f;//行间距
    
    NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:textStr attributes:@{NSParagraphStyleAttributeName:paraStyle}];
    self.contentLabel.attributedText = attrText;
    
    
}

- (void)setupSubviews {
    [super setupSubviews];
    
    UILabel *tipLabel = [[UILabel alloc] init];
    tipLabel.textColor = COLOR(0x334A60);
    tipLabel.font = [UIFont boldSystemFontOfSize:21];
    tipLabel.text = @"温馨提示：";
    [self.view addSubview:tipLabel];
    
    UILabel *contentLabel = [[UILabel alloc] init];
    contentLabel.textColor = COLOR(0x334A60);
    contentLabel.font = [UIFont systemFontOfSize:15];
    contentLabel.numberOfLines = 0;
    NSString *text = @"1.根据我国《合同法》、《电子签名法》以及其他相关法律法规，电子合同与纸质合同具有同等法律效应。\n2.合同是当事人基于信任，在协商的基础上意思表示一致的民事法律行为。合同履行过程中所承担的风险将由合同当事人自行承担，因此在签署前请务必确认对方的身份、联系方式的真实性及合同内容的准确性，谨慎处理。";
    //    [UILabel changeLineSpaceForLabel:contentLabel WithSpace:4];
    [self.view addSubview:contentLabel];
    self.contentLabel = contentLabel;
    
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    //    paraStyle.alignment = NSTextAlignmentLeft;  //对齐
    //    paraStyle.headIndent = 0.0f;//行首缩进
    //参数：（字体大小17号字乘以2，34f即首行空出两个字符）
    //        CGFloat emptylen = self.contentLabel.font.pointSize * 2;
    //        paraStyle.firstLineHeadIndent = emptylen;//首行缩进
    //    paraStyle.tailIndent = 0.0f;//行尾缩进
    paraStyle.lineSpacing = 15.0f;//行间距
    
    NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:text attributes:@{NSParagraphStyleAttributeName:paraStyle}];
    contentLabel.attributedText = attrText;

    UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [cancelButton setBackgroundColor:MAIN_TEXT_COLOR];
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton addTarget:self action:@selector(cancelButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:cancelButton];
    
    UIButton *continueButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [continueButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [continueButton setBackgroundColor:MAIN_COLOR];
    [continueButton setTitle:@"继续" forState:UIControlStateNormal];
    [continueButton addTarget:self action:@selector(continueButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:continueButton];
    
    // 自动布局
    CGFloat margin = 8.0;
    WeakSelf
    [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.view).offset(kTopHeight + (2 * margin));
        make.centerX.equalTo(weakSelf.view);
    }];
    

    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(tipLabel.mas_bottom).offset(margin);
        make.left.equalTo(weakSelf.view).offset(margin);
        make.right.equalTo(weakSelf.view).offset(-margin);
    }];
    
    [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.view.mas_centerX);
        make.height.mas_equalTo(44);
        if (@available(iOS 11.0, *)) {
            make.left.equalTo(weakSelf.view.mas_safeAreaLayoutGuideLeft);
            make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.left.equalTo(weakSelf.view);
            make.bottom.equalTo(weakSelf.view);
        }
    }];
    
    [continueButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.view.mas_centerX);
        make.height.mas_equalTo(44);
        if (@available(iOS 11.0, *)) {
            make.right.equalTo(weakSelf.view.mas_safeAreaLayoutGuideRight);
            make.bottom.equalTo(weakSelf.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.right.equalTo(weakSelf.view);
            make.bottom.equalTo(weakSelf.view);
        }
    }];
}

#pragma mark - 继续按钮点击事件
- (void)continueButtonClickAction {
    
    
}

- (void)cancelButtonClickAction {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
